package com.tang.system.controller;

import com.tang.system.service.ILoginService;
import com.tang.system.vo.LoginVo;
import com.tang.system.vo.Result;
import com.tang.system.vo.UserInfo;
import com.tang.utils.CommonUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    ILoginService loginService;

    @PostMapping("/login")
    public Result login(@RequestBody LoginVo user) {
        return Result.ok(loginService.login(user));
    }

    @GetMapping("/loadUserPermissions")
    public Result login() {
        UserInfo currentUser = CommonUtils.getCurrentUser();
        loginService.loadPermisstions(currentUser);
        return Result.ok(currentUser);
    }
}
